﻿using CID.Domain.Infrastructure;
using FluentNHibernate.Mapping;

namespace CID.Domain.Persistence.Mappings.Infrastructure
{
    public class TemplateMap : DescribedEntityMap<Template>
    {
        public const string DiscriminatorColumn = "Type";

        public TemplateMap() : base() 
        {
            Map(x => x.Enabled);
            Map(x => x.MultipleServersSupport);
            Map(x => x.Content).CustomSqlType("VARBINARY(MAX)");
            References<TemplateType>(x => x.Type).Column("TemplateType_id");
            HasMany<Parameter>(x => x.Parameters);
            DiscriminateSubClassesOnColumn(DiscriminatorColumn).Length(20);
        }
    }

    public class ActivationTemplateMap : SubclassMap<ActivationTemplate>
    {
        public ActivationTemplateMap()
        {
            DiscriminatorValue("Activation");
        }
    }

    public class DeactivationTemplateMap : SubclassMap<DeactivationTemplate>
    {
        public DeactivationTemplateMap()
        {
            DiscriminatorValue("Deactivation");
        }
    }

    public class DeploymentTemplateMap : SubclassMap<DeploymentTemplate>
    {
        public DeploymentTemplateMap()
        {
            DiscriminatorValue("Deployment");
        }
    }
}
